//
//  TTTTtestController.m
//  ProjectDemo
//
//  Created by IOS3 on 2018/11/6.
//  Copyright © 2018 IOS3. All rights reserved.
//

#import "TTTTtestController.h"
#import "Person.h"
#import "NSNull+test.h"
#import "TestPlayerController.h"
#import "TestZFPlayController.h"
#import "TestSJPlayerController.h"
#import "TestAudioController.h"
#import "TestAudio2Controller.h"
#import "TestSliderController.h"



@interface TTTTtestController ()

//@property (nonatomic, strong) UIImageView *navImageView;

@end

@implementation TTTTtestController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableVeiw registerClass:[UITableViewCell class] forCellReuseIdentifier:@"TTTTtestControllerCellID"];
    [self setupHaderView];
    
    
    
    [self.navigationController.navigationBar setBackgroundImage:UIImage.new forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setShadowImage:UIImage.new];
    
//    self.navImageView = self.navigationController.navigationBar.subviews.firstObject;
//    [self.navigationController.navigationBar.subviews makeObjectsPerformSelector:@selector(setAlpha:) withObject:[NSNumber numberWithFloat:0.00]];
//    self.navImageView.alpha = 0.0;
//    [self.navigationController.navigationBar setAlpha:0.0];
    
    
    
    
    
    [self test];
    
}


- (void)test {
 
//    id p = Person.new;
//    p = NSNull.new;
//    [p run];
//    [p testForword];
//    p[2];
    
//    NSArray *arr = @[];
//    arr[3];
    
//    [Person.new run];
    
    
    [Person.new run];
}


- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
    self.hbd_barAlpha = 1.f;
}


- (void)setupHaderView {
    
    self.tableVeiw.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    
    self.view.backgroundColor = UIColor.redColor;
    
    
    self.hbd_barAlpha = 0.f;
    self.navigationController.navigationBar.barTintColor = UIColor.redColor;
    
    
    
    
    
    
    self.tableVeiw.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, -TOP_HEIGHT, SCREEN_WIDTH, 300)];
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageWithColor:UIColor.blueColor];
    imageView.frame = CGRectMake(0, 0, SCREEN_WIDTH, 300);
    [view addSubview:imageView];
    
    self.tableVeiw.tableHeaderView = view;
    
}


- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat offsetY = scrollView.contentOffset.y;

    if (offsetY > TOP_HEIGHT) {
        offsetY = TOP_HEIGHT;
    }
    CGFloat a = offsetY / (TOP_HEIGHT + 1);
//    self.navImageView.alpha = a;
//    DLog(@">>>> %f", a);
    self.hbd_barAlpha = a;
    [self hbd_setNeedsUpdateNavigationBarAlpha];
//    DLog(@"%f", offsetY);

    

}



- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 20;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TTTTtestControllerCellID" forIndexPath:indexPath];
    cell.textLabel.text = [NSString stringWithFormat:@"section: %ld - row: %ld", indexPath.section, indexPath.row];
    cell.detailTextLabel.text = @"tesashfauljh";
    return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//    TestPlayerController *target = TestPlayerController.new;
//    TestZFPlayController *target = TestZFPlayController.new;
//    TestSJPlayerController *target = TestSJPlayerController.new;
//    TestAudioController *target = TestAudioController.new;
//    TestAudio2Controller *target = TestAudio2Controller.new;
    TestSliderController *target = TestSliderController.new;
    
    [self.navigationController pushViewController:target animated:true];
}

@end
